<!DOCTYPE html>
<html lang="zh-cn">
<!-- 测试宽度单位 -->

<head>
	<meta charset="utf-8" />
	<!-- 这句话非常关键 -->
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>测试宽度单位</title>
	<style>
		body {
			margin: 0;
		}


		.test {
			width: 375px;
			height: 100px;
			background-color: #0086B3;
			margin: 0 auto;
		}

		.viewport {
			line-height: 100px;
			background-color: red;
			color: antiquewhite;
			font-size: 50px;
			text-align: center;
			margin-bottom: 10px;
			overflow: hidden;
		}
	</style>
</head>

<body>
	<div id="pix" class="viewport">

	</div>
	<div class="viewport">
		<span id="sw"></span>
		×
		<span id="sh"></span>

	</div>
</body>

</html>
<script>

	function refresh() {
		pix.innerHTML = devicePixelRatio
		sw.innerHTML = document.documentElement.clientWidth;
		sh.innerHTML = document.documentElement.clientHeight;
	}

	refresh()
	window.onresize = refresh
</script>